home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / gpt32src.zip / TERM.C < prev    next >
C/C++ Source or Header  |  1992-03-25  |  55KB  |  1,732 lines

  1. #ifndef lint
  2. static char *RCSid = "$Id: term.c,v 3.26 92/03/24 22:34:41 woo Exp Locker: woo $";
  3. #endif
  4.  
  5. /* GNUPLOT - term.c */
  6. /*
  7.  * Copyright (C) 1986, 1987, 1990, 1991, 1992   Thomas Williams, Colin Kelley
  8.  *
  9.  * Permission to use, copy, and distribute this software and its
  10.  * documentation for any purpose with or without fee is hereby granted, 
  11.  * provided that the above copyright notice appear in all copies and 
  12.  * that both that copyright notice and this permission notice appear 
  13.  * in supporting documentation.
  14.  *
  15.  * Permission to modify the software is granted, but not the right to
  16.  * distribute the modified code.  Modifications are to be distributed 
  17.  * as patches to released version.
  18.  *  
  19.  * This software is provided "as is" without express or implied warranty.
  20.  * 
  21.  *
  22.  * AUTHORS
  23.  * 
  24.  *   Original Software:
  25.  *     Thomas Williams,  Colin Kelley.
  26.  * 
  27.  *   Gnuplot 2.0 additions:
  28.  *       Russell Lang, Dave Kotz, John Campbell.
  29.  *
  30.  *   Gnuplot 3.0 additions:
  31.  *       Gershon Elber and many others.
  32.  * 
  33.  * Send your comments or suggestions to 
  34.  *  info-gnuplot@ames.arc.nasa.gov.
  35.  * This is a mailing list; to join it send a note to 
  36.  *  info-gnuplot-request@ames.arc.nasa.gov.  
  37.  * Send bug reports to
  38.  *  bug-gnuplot@ames.arc.nasa.gov.
  39.  */
  40.  
  41. #include <stdio.h>
  42. #include "plot.h"
  43. #include "setshow.h"
  44. #include "term.h"
  45. #include "bitmap.h"
  46. #ifdef NEXT
  47. #include <stdlib.h>
  48. #include "EpsViewer.h"
  49. #endif /* NEXT */
  50.  
  51. /* for use by all drivers */
  52. #define sign(x) ((x) >= 0 ? 1 : -1)
  53. #define abs(x) ((x) >= 0 ? (x) : -(x))
  54. #define max(a,b) ((a) > (b) ? (a) : (b))
  55. #define min(a,b) ((a) < (b) ? (a) : (b))
  56.  
  57. BOOLEAN term_init;            /* true if terminal has been initialized */
  58.  
  59. extern FILE *outfile;
  60. extern char outstr[];
  61. extern BOOLEAN term_init;
  62. extern int term;
  63. extern float xsize, ysize;
  64.  
  65. extern char input_line[];
  66. extern struct lexical_unit token[];
  67. extern int num_tokens, c_token;
  68. extern struct value *const_express();
  69.  
  70. extern BOOLEAN interactive;
  71.  
  72. /*
  73.  * instead of <strings.h>
  74.  */
  75. extern char *strcpy();
  76. extern int strlen(), strcmp(), strncmp();
  77. #ifndef AMIGA_AC_5
  78. extern double sqrt();
  79. #endif
  80.  
  81. char *getenv();
  82.  
  83. #ifdef __TURBOC__
  84. char *turboc_init();
  85. #endif
  86. #ifdef PC
  87. void reopen_binary();
  88. #endif
  89. #ifdef vms
  90. char *vms_init();
  91. void vms_reset();
  92. void term_mode_tek();
  93. void term_mode_native();
  94. void term_pasthru();
  95. void term_nopasthru();
  96. void reopen_binary();
  97. void fflush_binary();
  98. #endif
  99.  
  100. /* This is needed because the unixplot library only writes to stdout. */
  101. #ifdef UNIXPLOT
  102. FILE save_stdout;
  103. #endif
  104. int unixplot=0;
  105.  
  106. #define NICE_LINE        0
  107. #define POINT_TYPES        6
  108.  
  109.  
  110. do_point(x,y,number)
  111. int x,y;
  112. int number;
  113. {
  114. register int htic,vtic;
  115. register struct termentry *t = &term_tbl[term];
  116.  
  117.      if (number < 0) {        /* do dot */
  118.         (*t->move)(x,y);
  119.         (*t->vector)(x,y);
  120.         return;
  121.     }
  122.  
  123.     number %= POINT_TYPES;
  124.     htic = (t->h_tic/2);    /* should be in term_tbl[] in later version */
  125.     vtic = (t->v_tic/2);    
  126.  
  127.     switch(number) {
  128.         case 0: /* do diamond */ 
  129.                 (*t->move)(x-htic,y);
  130.                 (*t->vector)(x,y-vtic);
  131.                 (*t->vector)(x+htic,y);
  132.                 (*t->vector)(x,y+vtic);
  133.                 (*t->vector)(x-htic,y);
  134.                 (*t->move)(x,y);
  135.                 (*t->vector)(x,y);
  136.                 break;
  137.         case 1: /* do plus */ 
  138.                 (*t->move)(x-htic,y);
  139.                 (*t->vector)(x-htic,y);
  140.                 (*t->vector)(x+htic,y);
  141.                 (*t->move)(x,y-vtic);
  142.                 (*t->vector)(x,y-vtic);
  143.                 (*t->vector)(x,y+vtic);
  144.                 break;
  145.         case 2: /* do box */ 
  146.                 (*t->move)(x-htic,y-vtic);
  147.                 (*t->vector)(x-htic,y-vtic);
  148.                 (*t->vector)(x+htic,y-vtic);
  149.                 (*t->vector)(x+htic,y+vtic);
  150.                 (*t->vector)(x-htic,y+vtic);
  151.                 (*t->vector)(x-htic,y-vtic);
  152.                 (*t->move)(x,y);
  153.                 (*t->vector)(x,y);
  154.                 break;
  155.         case 3: /* do X */ 
  156.                 (*t->move)(x-htic,y-vtic);
  157.                 (*t->vector)(x-htic,y-vtic);
  158.                 (*t->vector)(x+htic,y+vtic);
  159.                 (*t->move)(x-htic,y+vtic);
  160.                 (*t->vector)(x-htic,y+vtic);
  161.                 (*t->vector)(x+htic,y-vtic);
  162.                 break;
  163.         case 4: /* do triangle */ 
  164.                 (*t->move)(x,y+(4*vtic/3));
  165.                 (*t->vector)(x-(4*htic/3),y-(2*vtic/3));
  166.                 (*t->vector)(x+(4*htic/3),y-(2*vtic/3));
  167.                 (*t->vector)(x,y+(4*vtic/3));
  168.                 (*t->move)(x,y);
  169.                 (*t->vector)(x,y);
  170.                 break;
  171.         case 5: /* do star */ 
  172.                 (*t->move)(x-htic,y);
  173.                 (*t->vector)(x-htic,y);
  174.                 (*t->vector)(x+htic,y);
  175.                 (*t->move)(x,y-vtic);
  176.                 (*t->vector)(x,y-vtic);
  177.                 (*t->vector)(x,y+vtic);
  178.                 (*t->move)(x-htic,y-vtic);
  179.                 (*t->vector)(x-htic,y-vtic);
  180.                 (*t->vector)(x+htic,y+vtic);
  181.                 (*t->move)(x-htic,y+vtic);
  182.                 (*t->vector)(x-htic,y+vtic);
  183.                 (*t->vector)(x+htic,y-vtic);
  184.                 break;
  185.     }
  186. }
  187.  
  188.  
  189. /*
  190.  * general point routine
  191.  */
  192. line_and_point(x,y,number)
  193. int x,y,number;
  194. {
  195.     /* temporary(?) kludge to allow terminals with bad linetypes 
  196.         to make nice marks */
  197.  
  198.     (*term_tbl[term].linetype)(NICE_LINE);
  199.     do_point(x,y,number);
  200. }
  201.  
  202. /* 
  203.  * general arrow routine
  204.  */
  205. #define ROOT2 (1.41421)        /* sqrt of 2 */
  206.  
  207. do_arrow(sx, sy, ex, ey, head)
  208.     int sx,sy;            /* start point */
  209.     int ex, ey;            /* end point (point of arrowhead) */
  210.     BOOLEAN head;
  211. {
  212.     register struct termentry *t = &term_tbl[term];
  213.     int len = (t->h_tic + t->v_tic)/2; /* arrowhead size = avg of tic sizes */
  214.  
  215.     /* draw the line for the arrow. That's easy. */
  216.     (*t->move)(sx, sy);
  217.     (*t->vector)(ex, ey);
  218.  
  219.     if (head) {
  220.     /* now draw the arrow head. */
  221.     /* we put the arrowhead marks at 45 degrees to line */
  222.        if (sx == ex) {
  223.        /* vertical line, special case */
  224.           int delta = ((float)len / ROOT2 + 0.5);
  225.           if (sy < ey)
  226.               delta = -delta;    /* up arrow goes the other way */
  227.           (*t->move)(ex - delta, ey + delta);
  228.           (*t->vector)(ex,ey);
  229.           (*t->vector)(ex + delta, ey + delta);
  230.        } else {
  231.           int dx = sx - ex;
  232.           int dy = sy - ey;
  233.           double coeff = len / sqrt(2.0*((double)dx*(double)dx 
  234.                    + (double)dy*(double)dy));
  235.           int x,y;            /* one endpoint */
  236.  
  237.           x = (int)( ex + (dx + dy) * coeff );
  238.           y = (int)( ey + (dy - dx) * coeff );
  239.           (*t->move)(x,y);
  240.           (*t->vector)(ex,ey);
  241.  
  242.           x = (int)( ex + (dx - dy) * coeff );
  243.           y = (int)( ey + (dy + dx) * coeff );
  244.           (*t->vector)(x,y);
  245.        }
  246.     }
  247. }
  248.  
  249. #ifdef DUMB                    /* paper or glass dumb terminal */
  250. #include "term/dumb.trm"
  251. #endif
  252.  
  253.  
  254. #ifdef PC            /* all PC types */
  255. #include "term/pc.trm"
  256. #endif
  257.  
  258. /*
  259.    all TEK types (TEK,BITGRAPH,KERMIT,VTTEK,SELANAR) are ifdef'd in tek.trm,
  260.    but most require various TEK routines.  Hence TEK must be defined for
  261.    the others to compile.
  262. */
  263. #ifdef BITGRAPH
  264. # ifndef TEK
  265. #  define TEK
  266. # endif
  267. #endif
  268.  
  269. #ifdef SELENAR
  270. # ifndef TEK
  271. #  define TEK
  272. # endif
  273. #endif
  274.  
  275. #ifdef KERMIT
  276. # ifndef TEK
  277. #  define TEK
  278. # endif
  279. #endif
  280.  
  281. #ifdef LN03P
  282. # ifndef TEK
  283. #  define TEK
  284. # endif
  285. #endif
  286.  
  287. #ifdef VTTEK
  288. # ifndef TEK
  289. #  define TEK
  290. # endif
  291. #endif
  292.  
  293. #ifdef T410X        /* Tektronix 4106, 4107, 4109 and 420x terminals */
  294. #include "term/t410x.trm"
  295. #endif
  296.  
  297. #ifdef TEK            /* all TEK types, TEK, BBN, SELANAR, KERMIT, VTTEK */
  298. #include "term/tek.trm"
  299. #endif
  300.  
  301. #ifdef EPSONP    /* bit map types, EPSON, NEC, PROPRINTER, STAR Color */
  302. #include "term/epson.trm"
  303. #endif
  304.  
  305. #ifdef HPLJII        /* HP LaserJet II */
  306. #include "term/hpljii.trm"
  307. #endif
  308.  
  309. #ifdef HPLJIII /* HP LaserJet III in HPGL mode */
  310. #  ifndef HPGL
  311. #    define HPGL
  312. #  endif
  313. #endif
  314.  
  315. #ifdef FIG                /* Fig 1.4FS Interactive graphics program */
  316. #include "term/fig.trm"
  317. #include "term/bigfig.trm"
  318. #endif
  319.   
  320. #ifdef GPR              /* Apollo Graphics Primitive Resource (fixed-size window) */
  321. #include "term/gpr.trm"
  322. #endif /* GPR */
  323.  
  324. #ifdef APOLLO           /* Apollo Graphics Primitive Resource (resizable window) */
  325. #include "term/apollo.trm"
  326. #endif /* APOLLO */
  327.  
  328. #ifdef IMAGEN        /* IMAGEN printer */
  329. #include "term/imagen.trm"
  330. #endif
  331.  
  332. #ifdef EEPIC        /* EEPIC (LATEX) type */
  333. #include "term/eepic.trm"
  334. # ifndef LATEX
  335. #  define LATEX
  336. # endif
  337. #endif
  338.  
  339. #ifdef EMTEX        /* EMTEX (LATEX for PC) type */
  340. # ifndef LATEX
  341. #  define LATEX
  342. # endif
  343. #endif
  344.  
  345. #ifdef LATEX        /* LATEX type */
  346. #include "term/latex.trm"
  347. #endif
  348.  
  349. #ifdef PBM        /* PBMPLUS portable bitmap */
  350. #include "term/pbm.trm"
  351. #endif
  352.  
  353. #ifdef POSTSCRIPT    /* POSTSCRIPT type */
  354. #include "term/post.trm"
  355. #endif
  356.  
  357. #ifdef PRESCRIBE    /* PRESCRIBE type */
  358. #include "term/kyo.trm"
  359. #endif
  360.  
  361. #ifdef UNIXPC     /* unix-PC  ATT 7300 or 3b1 machine */
  362. #include "term/unixpc.trm"
  363. #endif /* UNIXPC */
  364.  
  365. #ifdef AED
  366. #include "term/aed.trm"
  367. #endif /* AED */
  368.  
  369. #ifdef AIFM
  370. #include "term/ai.trm"
  371. #endif /* AIFM */
  372.  
  373. #ifdef CGI
  374. #include "term/cgi.trm"
  375. #endif /* CGI */
  376.  
  377. #ifdef HP2648
  378. /* also works for HP2647 */
  379. #include "term/hp2648.trm"
  380. #endif /* HP2648 */
  381.  
  382. #ifdef HP26
  383. #include "term/hp26.trm"
  384. #endif /* HP26 */
  385.  
  386. #ifdef HP75
  387. #ifndef HPGL
  388. #define HPGL
  389. #endif
  390. #endif
  391.  
  392. /* HPGL - includes HP75 and HPLJIII in HPGL mode */
  393. #ifdef HPGL
  394. #include "term/hpgl.trm"
  395. #endif /* HPGL */
  396.  
  397. /* Roland DXY800A plotter driver by Martin Yii, eln557h@monu3.OZ 
  398.     and Russell Lang, rjl@monu1.cc.monash.oz */
  399. #ifdef DXY800A
  400. #include "term/dxy.trm"
  401. #endif /* DXY800A */
  402.  
  403. #ifdef IRIS4D
  404. #include "term/iris4d.trm"
  405. #endif /* IRIS4D */
  406.  
  407. #ifdef NEXT
  408. #include "term/next.trm"
  409. #endif /* NEXT */
  410.  
  411. #ifdef QMS
  412. #include "term/qms.trm"
  413. #endif /* QMS */
  414.  
  415. #ifdef REGIS
  416. #include "term/regis.trm"
  417. #endif /* REGIS */
  418.  
  419. #ifdef SUN
  420. #include "term/sun.trm"
  421. #endif /* SUN */
  422.  
  423. #ifdef VWS
  424. #include "term/vws.trm"
  425. #endif /* VWS */
  426.  
  427. #ifdef V384
  428. #include "term/v384.trm"
  429. #endif /* V384 */
  430.  
  431. #ifdef UNIXPLOT
  432. #include "term/unixplot.trm"
  433. #endif /* UNIXPLOT */
  434.  
  435. #ifdef X11
  436. #include "term/x11.trm"
  437. #endif /* X11 */
  438.  
  439. #ifdef DXF
  440. #include "term/dxf.trm"
  441. #endif /* DXF */
  442.   
  443. #ifdef AMIGASCREEN
  444. #include "term/amiga.trm"
  445. #endif /* AMIGASCREEN */
  446.  
  447.  
  448. /* Dummy functions for unavailable features */
  449.  
  450. /* change angle of text.  0 is horizontal left to right.
  451. * 1 is vertical bottom to top (90 deg rotate)  
  452. */
  453. static int null_text_angle()
  454. {
  455. return FALSE ;    /* can't be done */
  456. }
  457.  
  458. /* change justification of text.  
  459.  * modes are LEFT (flush left), CENTRE (centred), RIGHT (flush right)
  460.  */
  461. static int null_justify_text()
  462. {
  463. return FALSE ;    /* can't be done */
  464. }
  465.  
  466.  
  467. /* Change scale of plot.
  468.  * Parameters are x,y scaling factors for this plot.
  469.  * Some terminals (eg latex) need to do scaling themselves.
  470.  */
  471. static int null_scale()
  472. {
  473. return FALSE ;    /* can't be done */
  474. }
  475.  
  476. static int do_scale()
  477. {
  478. return TRUE ;    /* can be done */
  479. }
  480.  
  481. options_null()
  482. {
  483.     term_options[0] = '\0';    /* we have no options */
  484. }
  485.  
  486. static UNKNOWN_null()
  487. {
  488. }
  489.  
  490. /*
  491.  * term_tbl[] contains an entry for each terminal.  "unknown" must be the
  492.  *   first, since term is initialized to 0.
  493.  */
  494. struct termentry term_tbl[] = {
  495.     {"unknown", "Unknown terminal type - not a plotting device",
  496.       100, 100, 1, 1,
  497.       1, 1, options_null, UNKNOWN_null, UNKNOWN_null, 
  498.       UNKNOWN_null, null_scale, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, 
  499.       UNKNOWN_null, UNKNOWN_null, null_text_angle, 
  500.       null_justify_text, UNKNOWN_null, UNKNOWN_null}
  501.  
  502.     ,{"table", "Dump ASCII table of X Y [Z] values to output",
  503.       100, 100, 1, 1,
  504.       1, 1, options_null, UNKNOWN_null, UNKNOWN_null, 
  505.       UNKNOWN_null, null_scale, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, 
  506.       UNKNOWN_null, UNKNOWN_null, null_text_angle, 
  507.       null_justify_text, UNKNOWN_null, UNKNOWN_null}
  508.  
  509. #ifdef AMIGASCREEN
  510.     ,{"amiga", "Amiga Custom Screen",
  511.        AMIGA_XMAX, AMIGA_YMAX, AMIGA_VCHAR, AMIGA_HCHAR, 
  512.        AMIGA_VTIC, AMIGA_HTIC, options_null, AMIGA_init, AMIGA_reset, 
  513.        AMIGA_text, null_scale, AMIGA_graphics, AMIGA_move, AMIGA_vector,
  514.        AMIGA_linetype, AMIGA_put_text, null_text_angle, 
  515.        AMIGA_justify_text, do_point, do_arrow}
  516. #endif
  517.  
  518. #ifdef DUMB
  519.     ,{"dumb", "printer or glass dumb terminal",
  520.          DUMB_XMAX, DUMB_YMAX, 1, 1,
  521.          1, 1, DUMB_options, DUMB_init, DUMB_reset,
  522.          DUMB_text, null_scale, DUMB_graphics, DUMB_move, DUMB_vector,
  523.          DUMB_linetype, DUMB_put_text, null_text_angle,
  524.          null_justify_text, DUMB_point, DUMB_arrow}
  525. #endif
  526.  
  527. #ifdef PC
  528. #ifdef __TURBOC__
  529.  
  530.     ,{"egalib", "IBM PC/Clone with EGA graphics board",
  531.        EGALIB_XMAX, EGALIB_YMAX, EGALIB_VCHAR, EGALIB_HCHAR,
  532.        EGALIB_VTIC, EGALIB_HTIC, options_null, EGALIB_init, EGALIB_reset,
  533.        EGALIB_text, null_scale, EGALIB_graphics, EGALIB_move, EGALIB_vector,
  534.        EGALIB_linetype, EGALIB_put_text, EGALIB_text_angle, 
  535.        EGALIB_justify_text, do_point, do_arrow}
  536.  
  537.     ,{"vgalib", "IBM PC/Clone with VGA graphics board",
  538.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  539.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  540.        VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
  541.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  542.        VGA_justify_text, do_point, do_arrow}
  543.  
  544.     ,{"vgamono", "IBM PC/Clone with VGA Monochrome graphics board",
  545.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  546.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  547.        VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
  548.        VGAMONO_linetype, VGA_put_text, VGA_text_angle, 
  549.        VGA_justify_text, line_and_point, do_arrow}
  550.  
  551.     ,{"svga", "IBM PC/Clone with Super VGA graphics board",
  552.        SVGA_XMAX, SVGA_YMAX, SVGA_VCHAR, SVGA_HCHAR,
  553.        SVGA_VTIC, SVGA_HTIC, options_null, SVGA_init, SVGA_reset,
  554.        SVGA_text, null_scale, SVGA_graphics, SVGA_move, SVGA_vector,
  555.        SVGA_linetype, SVGA_put_text, SVGA_text_angle, 
  556.        SVGA_justify_text, do_point, do_arrow}
  557.  
  558.     ,{"mcga", "IBM PC/Clone with MCGA graphics board",
  559.        MCGA_XMAX, MCGA_YMAX, MCGA_VCHAR, MCGA_HCHAR,
  560.        MCGA_VTIC, MCGA_HTIC, options_null, MCGA_init, MCGA_reset,
  561.        MCGA_text, null_scale, MCGA_graphics, MCGA_move, MCGA_vector,
  562.        MCGA_linetype, MCGA_put_text, MCGA_text_angle, 
  563.        MCGA_justify_text, line_and_point, do_arrow}
  564.  
  565.     ,{"cga", "IBM PC/Clone with CGA graphics board",
  566.        CGA_XMAX, CGA_YMAX, CGA_VCHAR, CGA_HCHAR,
  567.        CGA_VTIC, CGA_HTIC, options_null, CGA_init, CGA_reset,
  568.        CGA_text, null_scale, CGA_graphics, CGA_move, CGA_vector,
  569.        CGA_linetype, CGA_put_text, MCGA_text_angle, 
  570.        CGA_justify_text, line_and_point, do_arrow}
  571.  
  572.     ,{"hercules", "IBM PC/Clone with Hercules graphics board",
  573.        HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
  574.        HERC_VTIC, HERC_HTIC, options_null, HERC_init, HERC_reset,
  575.        HERC_text, null_scale, HERC_graphics, HERC_move, HERC_vector,
  576.        HERC_linetype, HERC_put_text, MCGA_text_angle, 
  577.        HERC_justify_text, line_and_point, do_arrow}
  578. #ifdef ATT6300
  579.     ,{"att", "IBM PC/Clone with AT&T 6300 graphics board",
  580.        ATT_XMAX, ATT_YMAX, ATT_VCHAR, ATT_HCHAR,
  581.        ATT_VTIC, ATT_HTIC, options_null, ATT_init, ATT_reset,
  582.        ATT_text, null_scale, ATT_graphics, ATT_move, ATT_vector,
  583.        ATT_linetype, ATT_put_text, ATT_text_angle, 
  584.        ATT_justify_text, line_and_point, do_arrow}
  585. #endif
  586. #else                    /* TURBO */
  587.  
  588.     ,{"cga", "IBM PC/Clone with CGA graphics board",
  589.        CGA_XMAX, CGA_YMAX, CGA_VCHAR, CGA_HCHAR,
  590.        CGA_VTIC, CGA_HTIC, options_null, CGA_init, CGA_reset,
  591.        CGA_text, null_scale, CGA_graphics, CGA_move, CGA_vector,
  592.        CGA_linetype, CGA_put_text, CGA_text_angle, 
  593.        null_justify_text, line_and_point, do_arrow}
  594.  
  595.     ,{"egabios", "IBM PC/Clone with EGA graphics board (BIOS)",
  596.        EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR,
  597.        EGA_VTIC, EGA_HTIC, options_null, EGA_init, EGA_reset,
  598.        EGA_text, null_scale, EGA_graphics, EGA_move, EGA_vector,
  599.        EGA_linetype, EGA_put_text, EGA_text_angle, 
  600.        null_justify_text, do_point, do_arrow}
  601.  
  602.     ,{"vgabios", "IBM PC/Clone with VGA graphics board (BIOS)",
  603.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  604.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  605.        VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
  606.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  607.        null_justify_text, do_point, do_arrow}
  608.  
  609. #ifdef EGALIB
  610.     ,{"egalib", "IBM PC/Clone with EGA graphics board (LIB)",
  611.        EGALIB_XMAX, EGALIB_YMAX, EGALIB_VCHAR, EGALIB_HCHAR,
  612.        EGALIB_VTIC, EGALIB_HTIC, options_null, EGALIB_init, EGALIB_reset,
  613.        EGALIB_text, null_scale, EGALIB_graphics, EGALIB_move, EGALIB_vector,
  614.        EGALIB_linetype, EGALIB_put_text, null_text_angle, 
  615.        null_justify_text, do_point, do_arrow}
  616. #endif
  617.  
  618. #ifdef HERCULES
  619.     ,{"hercules", "IBM PC/Clone with Hercules graphics board",
  620.        HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
  621.        HERC_VTIC, HERC_HTIC, options_null, HERC_init, HERC_reset,
  622.        HERC_text, null_scale, HERC_graphics, HERC_move, HERC_vector,
  623.        HERC_linetype, HERC_put_text, HERC_text_angle, 
  624.        null_justify_text, line_and_point, do_arrow}
  625. #endif                    /* HERCULES */
  626.  
  627. #ifdef ATT6300
  628.     ,{"att", "AT&T PC/6300 graphics",
  629.        ATT_XMAX, ATT_YMAX, ATT_VCHAR, ATT_HCHAR,
  630.        ATT_VTIC, ATT_HTIC, options_null, ATT_init, ATT_reset,
  631.        ATT_text, null_scale, ATT_graphics, ATT_move, ATT_vector,
  632.        ATT_linetype, ATT_put_text, ATT_text_angle, 
  633.        null_justify_text, line_and_point, do_arrow}
  634. #endif
  635.  
  636. #ifdef CORONA
  637.     ,{"corona325", "Corona graphics ???",
  638.        COR_XMAX, COR_YMAX, COR_VCHAR, COR_HCHAR,
  639.        COR_VTIC, COR_HTIC, options_null, COR_init, COR_reset,
  640.        COR_text, null_scale, COR_graphics, COR_move, COR_vector,
  641.        COR_linetype, COR_put_text, COR_text_angle, 
  642.        null_justify_text, line_and_point, do_arrow}
  643. #endif                    /* CORONA */
  644. #endif                    /* TURBO */
  645. #endif                    /* PC */
  646.  
  647. #ifdef AED
  648.     ,{"aed512", "AED 512 Terminal",
  649.        AED5_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR,
  650.        AED_VTIC, AED_HTIC, options_null, AED_init, AED_reset, 
  651.        AED_text, null_scale, AED_graphics, AED_move, AED_vector, 
  652.        AED_linetype, AED_put_text, null_text_angle, 
  653.        null_justify_text, do_point, do_arrow}
  654.     ,{"aed767", "AED 767 Terminal",
  655.        AED_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR,
  656.        AED_VTIC, AED_HTIC, options_null, AED_init, AED_reset, 
  657.        AED_text, null_scale, AED_graphics, AED_move, AED_vector, 
  658.        AED_linetype, AED_put_text, null_text_angle, 
  659.        null_justify_text, do_point, do_arrow}
  660. #endif
  661.  
  662. #ifdef AIFM
  663.     ,{"aifm", "Adobe Illustrator 3.0 Format",
  664.        AI_XMAX, AI_YMAX, AI_VCHAR, AI_HCHAR, 
  665.        AI_VTIC, AI_HTIC, AI_options, AI_init, AI_reset, 
  666.        AI_text, null_scale, AI_graphics, AI_move, AI_vector, 
  667.        AI_linetype, AI_put_text, AI_text_angle, 
  668.        AI_justify_text, do_point, do_arrow}
  669. #endif
  670.  
  671. #ifdef APOLLO
  672.        ,{"apollo", "Apollo Graphics Primitive Resource, rescaling of subsequent plots after window resizing",
  673.        0, 0, 0, 0, /* APOLLO_XMAX, APOLLO_YMAX, APOLLO_VCHAR, APOLLO_HCHAR, are filled in at run-time */
  674.        APOLLO_VTIC, APOLLO_HTIC, options_null, APOLLO_init, APOLLO_reset,
  675.        APOLLO_text, null_scale, APOLLO_graphics, APOLLO_move, APOLLO_vector,
  676.        APOLLO_linetype, APOLLO_put_text, APOLLO_text_angle,
  677.        APOLLO_justify_text, line_and_point, do_arrow}
  678. #endif
  679.  
  680. #ifdef GPR
  681.        ,{"gpr", "Apollo Graphics Primitive Resource, fixed-size window",
  682.        GPR_XMAX, GPR_YMAX, GPR_VCHAR, GPR_HCHAR,
  683.        GPR_VTIC, GPR_HTIC, options_null, GPR_init, GPR_reset,
  684.        GPR_text, null_scale, GPR_graphics, GPR_move, GPR_vector,
  685.        GPR_linetype, GPR_put_text, GPR_text_angle,
  686.        GPR_justify_text, line_and_point, do_arrow}
  687. #endif
  688.  
  689. #ifdef BITGRAPH
  690.     ,{"bitgraph", "BBN Bitgraph Terminal",
  691.        BG_XMAX,BG_YMAX,BG_VCHAR, BG_HCHAR, 
  692.        BG_VTIC, BG_HTIC, options_null, BG_init, BG_reset, 
  693.        BG_text, null_scale, BG_graphics, BG_move, BG_vector,
  694.        BG_linetype, BG_put_text, null_text_angle, 
  695.        null_justify_text, line_and_point, do_arrow}
  696. #endif
  697.  
  698. #ifdef CGI
  699.     ,{"cgi", "SCO CGI drivers (requires CGIDISP or CGIPRNT env variable)",
  700.        CGI_XMAX, CGI_YMAX, 0, 0, 
  701.        CGI_VTIC, 0, options_null, CGI_init, CGI_reset, 
  702.        CGI_text, null_scale, CGI_graphics, CGI_move, CGI_vector, 
  703.        CGI_linetype, CGI_put_text, CGI_text_angle, 
  704.        CGI_justify_text, CGI_point, do_arrow}
  705.  
  706.     ,{"hcgi", "SCO CGI drivers (hardcopy, requires CGIPRNT env variable)",
  707.        CGI_XMAX, CGI_YMAX, 0, 0, 
  708.        CGI_VTIC, 0, options_null, HCGI_init, CGI_reset, 
  709.        CGI_text, null_scale, CGI_graphics, CGI_move, CGI_vector, 
  710.        CGI_linetype, CGI_put_text, CGI_text_angle, 
  711.        CGI_justify_text, CGI_point, do_arrow}
  712. #endif
  713.  
  714. #ifdef DXF
  715.     ,{"dxf", "dxf-file for AutoCad (default size 120x80)",
  716.        DXF_XMAX,DXF_YMAX,DXF_VCHAR, DXF_HCHAR,
  717.        DXF_VTIC, DXF_HTIC, options_null,DXF_init, DXF_reset,
  718.        DXF_text, null_scale, DXF_graphics, DXF_move, DXF_vector,
  719.        DXF_linetype, DXF_put_text, DXF_text_angle,
  720.        DXF_justify_text, do_point, do_arrow}
  721. #endif
  722.  
  723. #ifdef DXY800A
  724.     ,{"dxy800a", "Roland DXY800A plotter",
  725.        DXY_XMAX, DXY_YMAX, DXY_VCHAR, DXY_HCHAR,
  726.        DXY_VTIC, DXY_HTIC, options_null, DXY_init, DXY_reset,
  727.        DXY_text, null_scale, DXY_graphics, DXY_move, DXY_vector,
  728.        DXY_linetype, DXY_put_text, DXY_text_angle, 
  729.        null_justify_text, do_point, do_arrow}
  730. #endif
  731.  
  732. #ifdef EEPIC
  733.     ,{"eepic", "EEPIC -- extended LaTeX picture environment",
  734.        EEPIC_XMAX, EEPIC_YMAX, EEPIC_VCHAR, EEPIC_HCHAR, 
  735.        EEPIC_VTIC, EEPIC_HTIC, options_null, EEPIC_init, EEPIC_reset, 
  736.        EEPIC_text, EEPIC_scale, EEPIC_graphics, EEPIC_move, EEPIC_vector, 
  737.        EEPIC_linetype, EEPIC_put_text, EEPIC_text_angle, 
  738.        EEPIC_justify_text, EEPIC_point, EEPIC_arrow}
  739. #endif
  740.  
  741. #ifdef EMTEX
  742.    
  743.     ,{"emtex", "LATEX picture environment with emTeX specials",
  744.        LATEX_XMAX, LATEX_YMAX, LATEX_VCHAR, LATEX_HCHAR, 
  745.        LATEX_VTIC, LATEX_HTIC, options_null, EMTEX_init, EMTEX_reset, 
  746.        EMTEX_text, LATEX_scale, LATEX_graphics, LATEX_move, LATEX_vector, 
  747.        LATEX_linetype, LATEX_put_text, LATEX_text_angle, 
  748.        LATEX_justify_text, LATEX_point, LATEX_arrow}
  749. #endif
  750.  
  751. #ifdef EPS60
  752.     ,{"epson_60dpi", "Epson-style 60-dot per inch printers",
  753.        EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR,
  754.        EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset,
  755.        EPS60text, null_scale, EPS60graphics, EPSONmove, EPSONvector,
  756.        EPSONlinetype, EPSONput_text, EPSON_text_angle,
  757.        null_justify_text, do_point, do_arrow}
  758. #endif
  759.  
  760. #ifdef EPSONP
  761.     ,{"epson_lx800", "Epson LX-800, Star NL-10, NX-1000, PROPRINTER ...",
  762.        EPSONXMAX, EPSONYMAX, EPSONVCHAR, EPSONHCHAR, 
  763.        EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset, 
  764.        EPSONtext, null_scale, EPSONgraphics, EPSONmove, EPSONvector, 
  765.        EPSONlinetype, EPSONput_text, EPSON_text_angle, 
  766.        null_justify_text, line_and_point, do_arrow}
  767. #endif
  768.  
  769. #ifdef FIG
  770.     ,{"fig", "FIG graphics language: SunView or X graphics editor",
  771.        FIG_XMAX, FIG_YMAX, FIG_VCHAR, FIG_HCHAR, 
  772.        FIG_VTIC, FIG_HTIC, options_null, FIG_init, FIG_reset, 
  773.        FIG_text, null_scale, FIG_graphics, FIG_move, FIG_vector, 
  774.        FIG_linetype, FIG_put_text, FIG_text_angle, 
  775.        FIG_justify_text, do_point, FIG_arrow}
  776.     ,{"bfig", "FIG graphics language: SunView or X graphics editor. Large Graph",
  777.        BFIG_XMAX, BFIG_YMAX, BFIG_VCHAR, BFIG_HCHAR, 
  778.        BFIG_VTIC, BFIG_HTIC, options_null, FIG_init, FIG_reset, 
  779.        FIG_text, null_scale, FIG_graphics, FIG_move, BFIG_vector, 
  780.        FIG_linetype, BFIG_put_text, FIG_text_angle, 
  781.        FIG_justify_text, do_point, BFIG_arrow}
  782. #endif
  783.  
  784. #ifdef HP26
  785.     ,{"hp2623A", "HP2623A and maybe others",
  786.        HP26_XMAX, HP26_YMAX, HP26_VCHAR, HP26_HCHAR,
  787.        HP26_VTIC, HP26_HTIC, options_null, HP26_init, HP26_reset,
  788.        HP26_text, null_scale, HP26_graphics, HP26_move, HP26_vector,
  789.        HP26_linetype, HP26_put_text, null_text_angle, 
  790.        null_justify_text, line_and_point, do_arrow}
  791. #endif
  792.  
  793. #ifdef HP2648
  794.     ,{"hp2648", "HP2648 and HP2647",
  795.        HP2648XMAX, HP2648YMAX, HP2648VCHAR, HP2648HCHAR, 
  796.        HP2648VTIC, HP2648HTIC, options_null, HP2648init, HP2648reset, 
  797.        HP2648text, null_scale, HP2648graphics, HP2648move, HP2648vector, 
  798.        HP2648linetype, HP2648put_text, HP2648_text_angle, 
  799.        null_justify_text, line_and_point, do_arrow}
  800. #endif
  801.  
  802. #ifdef HP75
  803.     ,{"hp7580B", "HP7580, and probably other HPs (4 pens)",
  804.        HPGL_XMAX, HPGL_YMAX, HPGL_VCHAR, HPGL_HCHAR,
  805.        HPGL_VTIC, HPGL_HTIC, options_null, HPGL_init, HPGL_reset,
  806.        HPGL_text, null_scale, HPGL_graphics, HPGL_move, HPGL_vector,
  807.        HP75_linetype, HPGL_put_text, HPGL_text_angle, 
  808.        null_justify_text, do_point, do_arrow}
  809. #endif
  810.  
  811. #ifdef HPGL
  812.     ,{"hpgl", "HP7475 and (hopefully) lots of others (6 pens)",
  813.        HPGL_XMAX, HPGL_YMAX, HPGL_VCHAR, HPGL_HCHAR,
  814.        HPGL_VTIC, HPGL_HTIC, options_null, HPGL_init, HPGL_reset,
  815.        HPGL_text, null_scale, HPGL_graphics, HPGL_move, HPGL_vector,
  816.        HPGL_linetype, HPGL_put_text, HPGL_text_angle, 
  817.        null_justify_text, do_point, do_arrow}
  818. #endif
  819.  
  820. #ifdef HPLJII
  821.     ,{"hpljii", "HP Laserjet series II, [75 100 150 300]",
  822.        HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR,
  823.        HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJIIoptions,
  824.        HPLJIIinit, HPLJIIreset, HPLJIItext, null_scale,
  825.        HPLJIIgraphics, HPLJIImove, HPLJIIvector, HPLJIIlinetype,
  826.        HPLJIIput_text, HPLJIItext_angle, null_justify_text, line_and_point,
  827.        do_arrow}
  828.     ,{"hpdj", "HP DeskJet 500, [75 100 150 300]",
  829.        HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR,
  830.        HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJIIoptions,
  831.        HPLJIIinit, HPLJIIreset, HPDJtext, null_scale,
  832.        HPDJgraphics, HPLJIImove, HPLJIIvector, HPLJIIlinetype,
  833.        HPDJput_text, HPDJtext_angle, null_justify_text, line_and_point,
  834.        do_arrow}
  835. #endif
  836.  
  837. #ifdef HPLJIII
  838.     ,{"pcl5_port", "HP laserjet iii (using HPGL plot vectors), portrait mode",
  839.     PCL_YMAX, PCL_XMAX, PCL_VCHAR, PCL_HCHAR,
  840.     PCL_VTIC, PCL_HTIC, options_null, PCL_PORT_init, PCL_reset,
  841.     PCL_text, null_scale, PCL_graphics, HPGL_move, HPGL_vector,
  842.     HPGL_linetype, PCL_put_text, HPGL_text_angle,
  843.     null_justify_text, do_point, do_arrow}
  844.      ,{"pcl5_land", "HP laserjet iii (using HPGL plot vectors), landscape mode",
  845.     PCL_XMAX, PCL_YMAX, PCL_VCHAR, PCL_HCHAR,
  846.     PCL_VTIC, PCL_HTIC, options_null, PCL_LAND_init, PCL_reset,
  847.     PCL_text, null_scale, PCL_graphics, HPGL_move, HPGL_vector,
  848.     HPGL_linetype, PCL_put_text, HPGL_text_angle,
  849.     null_justify_text, do_point, do_arrow}
  850. #endif
  851.  
  852. #ifdef IMAGEN
  853.     ,{"imagen", "Imagen laser printer",
  854.        IMAGEN_XMAX, IMAGEN_YMAX, IMAGEN_VCHAR, IMAGEN_HCHAR, 
  855.        IMAGEN_VTIC, IMAGEN_HTIC, options_null, IMAGEN_init, IMAGEN_reset, 
  856.        IMAGEN_text, null_scale, IMAGEN_graphics, IMAGEN_move, 
  857.        IMAGEN_vector, IMAGEN_linetype, IMAGEN_put_text, IMAGEN_text_angle,
  858.        IMAGEN_justify_text, line_and_point, do_arrow}
  859. #endif
  860.  
  861. #ifdef IRIS4D
  862.     ,{"iris4d", "Silicon Graphics IRIS 4D Series Computer",
  863.        IRIS4D_XMAX, IRIS4D_YMAX, IRIS4D_VCHAR, IRIS4D_HCHAR, 
  864.        IRIS4D_VTIC, IRIS4D_HTIC, IRIS4D_options, IRIS4D_init, IRIS4D_reset, 
  865.        IRIS4D_text, null_scale, IRIS4D_graphics, IRIS4D_move, IRIS4D_vector,
  866.        IRIS4D_linetype, IRIS4D_put_text, null_text_angle, 
  867.        null_justify_text, do_point, do_arrow}
  868. #endif
  869.  
  870. #ifdef KERMIT
  871.     ,{"kc_tek40xx", "Kermit-MS tek40xx terminal emulator - color",
  872.        TEK40XMAX,TEK40YMAX,TEK40VCHAR, KTEK40HCHAR, 
  873.        TEK40VTIC, TEK40HTIC, options_null, TEK40init, KTEK40reset, 
  874.        KTEK40Ctext, null_scale, KTEK40graphics, TEK40move, TEK40vector, 
  875.        KTEK40Clinetype, TEK40put_text, null_text_angle, 
  876.        null_justify_text, do_point, do_arrow}
  877.     ,{"km_tek40xx", "Kermit-MS tek40xx terminal emulator - monochrome",
  878.        TEK40XMAX,TEK40YMAX,TEK40VCHAR, KTEK40HCHAR, 
  879.        TEK40VTIC, TEK40HTIC, options_null, TEK40init, KTEK40reset, 
  880.        TEK40text, null_scale, KTEK40graphics, TEK40move, TEK40vector, 
  881.        KTEK40Mlinetype, TEK40put_text, null_text_angle, 
  882.        null_justify_text, line_and_point, do_arrow}
  883. #endif
  884.  
  885. #ifdef LATEX
  886.     ,{"latex", "LaTeX picture environment",
  887.        LATEX_XMAX, LATEX_YMAX, LATEX_VCHAR, LATEX_HCHAR, 
  888.        LATEX_VTIC, LATEX_HTIC, options_null, LATEX_init, LATEX_reset, 
  889.        LATEX_text, LATEX_scale, LATEX_graphics, LATEX_move, LATEX_vector, 
  890.        LATEX_linetype, LATEX_put_text, LATEX_text_angle, 
  891.        LATEX_justify_text, LATEX_point, LATEX_arrow}
  892. #endif
  893.  
  894. #ifdef LN03P
  895.      ,{"ln03", "LN03-plus laser printer in tektronix mode",
  896.     TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR,
  897.     TEK40VTIC, TEK40HTIC, options_null, LN03Pinit, LN03Preset,
  898.     TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector,
  899.     TEK40linetype, TEK40put_text, null_text_angle,
  900.     null_justify_text, line_and_point, do_arrow}
  901. #endif
  902.  
  903. #ifdef NEC
  904.     ,{"nec_cp6m", "NEC printer CP6, Epson LQ-800 Monochrome",
  905.        NECXMAX, NECYMAX, NECVCHAR, NECHCHAR, 
  906.        NECVTIC, NECHTIC, options_null, NECinit, NECreset, 
  907.        NECtext, null_scale, NECMgraphics, NECmove, NECvector, 
  908.        NECMlinetype, NECput_text, NEC_text_angle, 
  909.        null_justify_text, line_and_point, do_arrow}
  910.     ,{"nec_cp6c", "NEC printer CP6 Color",
  911.        NECXMAX, NECYMAX, NECVCHAR, NECHCHAR, 
  912.        NECVTIC, NECHTIC, options_null, NECinit, NECreset, 
  913.        NECtext, null_scale, NECCgraphics, NECmove, NECvector, 
  914.        NECClinetype, NECput_text, NEC_text_angle, 
  915.        null_justify_text, do_point, do_arrow}
  916.     ,{"nec_cp6d", "NEC printer CP6, Epson LQ-800 Draft monochrome",
  917.        NECXMAX, NECYMAX, NECVCHAR, NECHCHAR, 
  918.        NECVTIC, NECHTIC, options_null, NECinit, NECreset, 
  919.        NECdraft_text, null_scale, NECMgraphics, NECmove, NECvector, 
  920.        NECMlinetype, NECput_text, NEC_text_angle, 
  921.        null_justify_text, line_and_point, do_arrow}
  922. #endif
  923.  
  924. #ifdef NEXT
  925.     ,{"next", "NeXTstep window system",
  926.        NEXT_XMAX, NEXT_YMAX, NEXT_VCHAR, NEXT_HCHAR, 
  927.        NEXT_VTIC, NEXT_HTIC, NEXT_options, NEXT_init, NEXT_reset, 
  928.        NEXT_text, do_scale, NEXT_graphics, NEXT_move, NEXT_vector, 
  929.        NEXT_linetype, NEXT_put_text, NEXT_text_angle, 
  930.        NEXT_justify_text, NEXT_point, do_arrow}
  931. #endif /* The postscript driver with NXImage displaying the postscript on screen */
  932.  
  933. #ifdef PBM
  934.     ,{"pbm", "Portable bitmap",
  935.        PBM_XMAX, PBM_YMAX, PBM_VCHAR,
  936.        PBM_HCHAR, PBM_VTIC, PBM_HTIC, PBMoptions,
  937.        PBMinit, PBMreset, PBMtext, null_scale,
  938.        PBMgraphics, PBMmove, PBMvector, PBMlinetype,
  939.        PBMput_text, PBMtext_angle, null_justify_text, line_and_point,
  940.        do_arrow}
  941.     ,{"pgm", "Portable graymap",
  942.        PBM_XMAX, PBM_YMAX, PBM_VCHAR,
  943.        PBM_HCHAR, PBM_VTIC, PBM_HTIC, PBMoptions,
  944.        PBMinit, PBMreset, PGMtext, null_scale,
  945.        PGMgraphics, PBMmove, PBMvector, PGMlinetype,
  946.        PBMput_text, PBMtext_angle, null_justify_text, do_point,
  947.        do_arrow}
  948.     ,{"ppm", "Portable pixmap (color)",
  949.        PBM_XMAX, PBM_YMAX, PBM_VCHAR,
  950.        PBM_HCHAR, PBM_VTIC, PBM_HTIC, PBMoptions,
  951.        PBMinit, PBMreset, PPMtext, null_scale,
  952.        PPMgraphics, PBMmove, PBMvector, PPMlinetype,
  953.        PBMput_text, PBMtext_angle, null_justify_text, do_point,
  954.        do_arrow}
  955. #endif
  956.  
  957. #ifdef POSTSCRIPT
  958.     ,{"postscript", "PostScript graphics language [mode \042fontname\042 font_size]",
  959.        PS_XMAX, PS_YMAX, PS_VCHAR, PS_HCHAR, 
  960.        PS_VTIC, PS_HTIC, PS_options, PS_init, PS_reset, 
  961.        PS_text, null_scale, PS_graphics, PS_move, PS_vector, 
  962.        PS_linetype, PS_put_text, PS_text_angle, 
  963.        PS_justify_text, PS_point, do_arrow}
  964. #endif
  965.  
  966. #ifdef PRESCRIBE
  967.     ,{"prescribe", "Prescribe - for the Kyocera Laser Printer",
  968.     PRE_XMAX, PRE_YMAX, PRE_VCHAR, PRE_HCHAR, 
  969.     PRE_VTIC, PRE_HTIC, options_null, PRE_init, PRE_reset, 
  970.     PRE_text, null_scale, PRE_graphics, PRE_move, PRE_vector, 
  971.     PRE_linetype, PRE_put_text, null_text_angle, 
  972.     PRE_justify_text, line_and_point, do_arrow}
  973.     ,{"kyo", "Kyocera Laser Printer with Courier font",
  974.     PRE_XMAX, PRE_YMAX, KYO_VCHAR, KYO_HCHAR, 
  975.     PRE_VTIC, PRE_HTIC, options_null, KYO_init, PRE_reset, 
  976.     PRE_text, null_scale, PRE_graphics, PRE_move, PRE_vector, 
  977.     PRE_linetype, PRE_put_text, null_text_angle, 
  978.     PRE_justify_text, line_and_point, do_arrow}
  979. #endif /* PRESCRIBE */
  980.  
  981. #ifdef QMS
  982.     ,{"qms", "QMS/QUIC Laser printer (also Talaris 1200 and others)",
  983.        QMS_XMAX,QMS_YMAX, QMS_VCHAR, QMS_HCHAR, 
  984.        QMS_VTIC, QMS_HTIC, options_null, QMS_init,QMS_reset, 
  985.        QMS_text, null_scale, QMS_graphics, QMS_move, QMS_vector,
  986.        QMS_linetype,QMS_put_text, null_text_angle, 
  987.        null_justify_text, line_and_point, do_arrow}
  988. #endif
  989.  
  990. #ifdef REGIS
  991.     ,{"regis", "REGIS graphics language",
  992.        REGISXMAX, REGISYMAX, REGISVCHAR, REGISHCHAR, 
  993.        REGISVTIC, REGISHTIC, options_null, REGISinit, REGISreset, 
  994.        REGIStext, null_scale, REGISgraphics, REGISmove, REGISvector,
  995.        REGISlinetype, REGISput_text, REGIStext_angle, 
  996.        null_justify_text, line_and_point, do_arrow}
  997. #endif
  998.  
  999.  
  1000. #ifdef SELANAR
  1001.     ,{"selanar", "Selanar",
  1002.        TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR, 
  1003.        TEK40VTIC, TEK40HTIC, options_null, SEL_init, SEL_reset, 
  1004.        SEL_text, null_scale, SEL_graphics, TEK40move, TEK40vector, 
  1005.        TEK40linetype, TEK40put_text, null_text_angle, 
  1006.        null_justify_text, line_and_point, do_arrow}
  1007. #endif
  1008.  
  1009. #ifdef STARC
  1010.     ,{"starc", "Star Color Printer",
  1011.        STARCXMAX, STARCYMAX, STARCVCHAR, STARCHCHAR, 
  1012.        STARCVTIC, STARCHTIC, options_null, STARCinit, STARCreset, 
  1013.        STARCtext, null_scale, STARCgraphics, STARCmove, STARCvector, 
  1014.        STARClinetype, STARCput_text, STARC_text_angle, 
  1015.        null_justify_text, line_and_point, do_arrow}
  1016. #endif
  1017.  
  1018. #ifdef SUN
  1019.     ,{"sun", "SunView window system",
  1020.        SUN_XMAX, SUN_YMAX, SUN_VCHAR, SUN_HCHAR, 
  1021.        SUN_VTIC, SUN_HTIC, options_null, SUN_init, SUN_reset, 
  1022.        SUN_text, null_scale, SUN_graphics, SUN_move, SUN_vector,
  1023.        SUN_linetype, SUN_put_text, null_text_angle, 
  1024.        SUN_justify_text, line_and_point, do_arrow}
  1025. #endif
  1026.  
  1027. #ifdef VWS
  1028.     ,{"VWS", "VAX Windowing System (UIS)",
  1029.            VWS_XMAX, VWS_YMAX, VWS_VCHAR, VWS_HCHAR,
  1030.            VWS_VTIC, VWS_HTIC, options_null, VWS_init, VWS_reset,
  1031.            VWS_text, null_scale, VWS_graphics, VWS_move, VWS_vector,
  1032.            VWS_linetype, VWS_put_text, VWS_text_angle,
  1033.            VWS_justify_text, do_point, do_arrow}
  1034. #endif
  1035.  
  1036. #ifdef TANDY60
  1037.     ,{"tandy_60dpi", "Tandy DMP-130 series 60-dot per inch graphics",
  1038.        EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR,
  1039.        EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset,
  1040.        TANDY60text, null_scale, EPS60graphics, EPSONmove, EPSONvector,
  1041.        EPSONlinetype, EPSONput_text, EPSON_text_angle,
  1042.        null_justify_text, do_point, do_arrow}
  1043. #endif
  1044.  
  1045. #ifdef T410X
  1046.     ,{"tek410x", "Tektronix 4106, 4107, 4109 and 420X terminals",
  1047.        T410XXMAX, T410XYMAX, T410XVCHAR, T410XHCHAR, 
  1048.        T410XVTIC, T410XHTIC, options_null, T410X_init, T410X_reset, 
  1049.        T410X_text, null_scale, T410X_graphics, T410X_move, T410X_vector, 
  1050.        T410X_linetype, T410X_put_text, T410X_text_angle, 
  1051.        null_justify_text, T410X_point, do_arrow}
  1052. #endif
  1053.  
  1054. #ifdef TEK
  1055.     ,{"tek40xx", "Tektronix 4010 and others; most TEK emulators",
  1056.        TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR, 
  1057.        TEK40VTIC, TEK40HTIC, options_null, TEK40init, TEK40reset, 
  1058.        TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector, 
  1059.        TEK40linetype, TEK40put_text, null_text_angle, 
  1060.        null_justify_text, line_and_point, do_arrow}
  1061. #endif
  1062.  
  1063. #ifdef UNIXPLOT
  1064.     ,{"unixplot", "Unix plotting standard (see plot(1))",
  1065.        UP_XMAX, UP_YMAX, UP_VCHAR, UP_HCHAR, 
  1066.        UP_VTIC, UP_HTIC, options_null, UP_init, UP_reset, 
  1067.        UP_text, null_scale, UP_graphics, UP_move, UP_vector, 
  1068.        UP_linetype, UP_put_text, null_text_angle, 
  1069.        null_justify_text, line_and_point, do_arrow}
  1070. #endif
  1071.     
  1072. #ifdef UNIXPC
  1073.     ,{"unixpc", "AT&T 3b1 or AT&T 7300 Unix PC",
  1074.        uPC_XMAX, uPC_YMAX, uPC_VCHAR, uPC_HCHAR, 
  1075.        uPC_VTIC, uPC_HTIC, options_null, uPC_init, uPC_reset, 
  1076.        uPC_text, null_scale, uPC_graphics, uPC_move, uPC_vector,
  1077.        uPC_linetype, uPC_put_text, uPC_text_angle, 
  1078.        null_justify_text, line_and_point, do_arrow}
  1079. #endif
  1080.  
  1081. #ifdef V384
  1082.     ,{"vx384", "Vectrix 384 and Tandy color printer",
  1083.        V384_XMAX, V384_YMAX, V384_VCHAR, V384_HCHAR, 
  1084.        V384_VTIC, V384_HTIC, options_null, V384_init, V384_reset, 
  1085.        V384_text, null_scale, V384_graphics, V384_move, V384_vector, 
  1086.        V384_linetype, V384_put_text, null_text_angle, 
  1087.        null_justify_text, do_point, do_arrow}
  1088. #endif
  1089.  
  1090. #ifdef VTTEK
  1091.     ,{"vttek", "VT-like tek40xx terminal emulator",
  1092.        TEK40XMAX,TEK40YMAX,TEK40VCHAR, TEK40HCHAR,
  1093.        TEK40VTIC, TEK40HTIC, options_null, VTTEK40init, VTTEK40reset,
  1094.        TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector,
  1095.        VTTEK40linetype, VTTEK40put_text, null_text_angle,
  1096.        null_justify_text, line_and_point, do_arrow}
  1097. #endif
  1098.  
  1099. #ifdef X11
  1100.     ,{"x11", "X11 Window System",
  1101.        X11_XMAX, X11_YMAX, X11_VCHAR, X11_HCHAR, 
  1102.        X11_VTIC, X11_HTIC, options_null, X11_init, X11_reset, 
  1103.        X11_text, null_scale, X11_graphics, X11_move, X11_vector, 
  1104.        X11_linetype, X11_put_text, null_text_angle, 
  1105.        X11_justify_text, line_and_point, do_arrow}
  1106.     ,{"X11", "X11 Window System - multi-color points",
  1107.        X11_XMAX, X11_YMAX, X11_VCHAR, X11_HCHAR, 
  1108.        X11_VTIC, X11_HTIC, options_null, X11_init, X11_reset, 
  1109.        X11_text, null_scale, X11_graphics, X11_move, X11_vector, 
  1110.        X11_linetype, X11_put_text, null_text_angle, 
  1111.        X11_justify_text, do_point, do_arrow}
  1112. #endif
  1113. };
  1114.  
  1115. #define TERMCOUNT (sizeof(term_tbl)/sizeof(struct termentry))
  1116.  
  1117.  
  1118. list_terms()
  1119. {
  1120. register int i;
  1121.  
  1122.     fprintf(stderr,"\nAvailable terminal types:\n");
  1123.     for (i = 0; i < TERMCOUNT; i++)
  1124.         fprintf(stderr,"  %15s  %s\n",
  1125.                term_tbl[i].name, term_tbl[i].description);
  1126.     (void) putc('\n',stderr);
  1127. }
  1128.  
  1129.  
  1130. /* set_term: get terminal number from name on command line */
  1131. /* will change 'term' variable if successful */
  1132. int                        /* term number */
  1133. set_term(c_token)
  1134. int c_token;
  1135. {
  1136.     register int t;
  1137.     char *input_name;
  1138.  
  1139.     if (!token[c_token].is_token)
  1140.      int_error("terminal name expected",c_token);
  1141.     t = -1;
  1142.     input_name = input_line + token[c_token].start_index;
  1143.     t = change_term(input_name, token[c_token].length);
  1144.     if (t == -1)
  1145.      int_error("unknown terminal type; type just 'set terminal' for a list",
  1146.              c_token);
  1147.     if (t == -2)
  1148.      int_error("ambiguous terminal name; type just 'set terminal' for a list",
  1149.              c_token);
  1150.  
  1151.     /* otherwise the type was changed */
  1152.  
  1153.     return(t);
  1154. }
  1155.  
  1156. /* change_term: get terminal number from name and set terminal type */
  1157. /* returns -1 if unknown, -2 if ambiguous, >=0 is terminal number */
  1158. int
  1159. change_term(name, length)
  1160.     char *name;
  1161.     int length;
  1162. {
  1163.     int i, t = -1;
  1164.  
  1165.     for (i = 0; i < TERMCOUNT; i++) {
  1166.        if (!strncmp(name,term_tbl[i].name,length)) {
  1167.           if (t != -1)
  1168.             return(-2);    /* ambiguous */
  1169.           t = i;
  1170.        }
  1171.     }
  1172.  
  1173.     if (t == -1)            /* unknown */
  1174.      return(t);
  1175.  
  1176.     /* Success: set terminal type now */
  1177.  
  1178.     term = t;
  1179.     term_init = FALSE;
  1180.     name = term_tbl[term].name;
  1181.  
  1182.     /* Special handling for unixplot term type */
  1183.     if (!strncmp("unixplot",name,8)) {
  1184.        UP_redirect (2);  /* Redirect actual stdout for unixplots */
  1185.     } else if (unixplot) {
  1186.        UP_redirect (3);  /* Put stdout back together again. */
  1187.     }
  1188.  
  1189.     if (interactive)
  1190.      fprintf(stderr, "Terminal type set to '%s'\n", name);
  1191.  
  1192.     return(t);
  1193. }
  1194.  
  1195. /*
  1196.    Routine to detect what terminal is being used (or do anything else
  1197.    that would be nice).  One anticipated (or allowed for) side effect
  1198.    is that the global ``term'' may be set. 
  1199.    The environment variable GNUTERM is checked first; if that does
  1200.    not exist, then the terminal hardware is checked, if possible, 
  1201.    and finally, we can check $TERM for some kinds of terminals.
  1202. */
  1203. /* thanks to osupyr!alden (Dave Alden) for the original GNUTERM code */
  1204. init_terminal()
  1205. {
  1206.     char *term_name = NULL;
  1207.     int t;
  1208.     char *term = NULL;        /* from TERM environment var */
  1209. #ifdef X11
  1210.     char *display = NULL;
  1211. #endif
  1212.     char *gnuterm = NULL;
  1213.  
  1214.     /* GNUTERM environment variable is primary */
  1215.     gnuterm = getenv("GNUTERM");
  1216.     if (gnuterm != (char *)NULL) {
  1217.      term_name = gnuterm;
  1218. #ifdef __TURBOC__
  1219.          get_path();   /* So *_init() can find the BGI driver */
  1220. #endif
  1221.     }
  1222.     else {
  1223. #ifdef __TURBOC__
  1224.        term_name = turboc_init();
  1225.        term = (char *)NULL; /* shut up turbo C */
  1226. #endif
  1227.        
  1228. #ifdef vms
  1229.        term_name = vms_init();
  1230. #endif
  1231.  
  1232. #ifdef NEXT
  1233.     term = getenv("TERM");
  1234.     if (term_name == (char *)NULL
  1235.         && term != (char *)NULL && strcmp(term,"next") == 0)
  1236.           term_name = "next";
  1237. #endif /* NeXT */
  1238.        
  1239. #ifdef SUN
  1240.        term = getenv("TERM");    /* try $TERM */
  1241.        if (term_name == (char *)NULL
  1242.           && term != (char *)NULL && strcmp(term, "sun") == 0)
  1243.         term_name = "sun";
  1244. #endif /* sun */
  1245.  
  1246. #ifdef GPR
  1247.    if (gpr_isa_pad()) term_name = "gpr";       /* find out whether stdout is a DM pad. See term/gpr.trm */
  1248. #else
  1249. #ifdef APOLLO
  1250.    if (apollo_isa_pad()) term_name = "apollo"; /* find out whether stdout is a DM pad. See term/apollo.trm */
  1251. #endif /* APOLLO */
  1252. #endif /* GPR    */
  1253.  
  1254. #ifdef X11
  1255.        term = getenv("TERM");    /* try $TERM */
  1256.        if (term_name == (char *)NULL
  1257.           && term != (char *)NULL && strcmp(term, "xterm") == 0)
  1258.         term_name = "x11";
  1259.        display = getenv("DISPLAY");
  1260.        if (term_name == (char *)NULL && display != (char *)NULL)
  1261.         term_name = "x11";
  1262. #endif /* x11 */
  1263.  
  1264. #ifdef AMIGASCREEN
  1265.        term_name = "amiga";
  1266. #endif
  1267.  
  1268. #ifdef UNIXPC
  1269.            if (iswind() == 0) {
  1270.               term_name = "unixpc";
  1271.            }
  1272. #endif /* unixpc */
  1273.  
  1274. #ifdef CGI
  1275.        if (getenv("CGIDISP") || getenv("CGIPRNT"))
  1276.          term_name = "cgi";
  1277. #endif /*CGI */
  1278.     }
  1279.  
  1280.     /* We have a name, try to set term type */
  1281.     if (term_name != NULL && *term_name != '\0') {
  1282.        t = change_term(term_name, strlen(term_name));
  1283.        if (t == -1)
  1284.         fprintf(stderr, "Unknown terminal name '%s'\n", term_name);
  1285.        else if (t == -2)
  1286.         fprintf(stderr, "Ambiguous terminal name '%s'\n", term_name);
  1287.        else                /* successful */
  1288.         ;
  1289.     }
  1290. }
  1291.  
  1292.  
  1293. #ifdef __TURBOC__
  1294. char *
  1295. turboc_init()
  1296. {
  1297.   int g_driver,g_mode;
  1298.   char far *c1,*c2;
  1299.   char *term_name = NULL;
  1300.   struct text_info tinfo;       /* So we can restore starting text mode. */
  1301.  
  1302. /* Some of this code including BGI drivers is copyright Borland Intl. */
  1303.     g_driver=DETECT;
  1304.           get_path();
  1305.     gettextinfo(&tinfo);
  1306.         initgraph(&g_driver,&g_mode,path);
  1307.         c1=getdrivername();
  1308.         c2=getmodename(g_mode);
  1309.           switch (g_driver){
  1310.             case -2: fprintf(stderr,"Graphics card not detected.\n");
  1311.                      break;
  1312.             case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1313.                      break;
  1314.             case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1315.                      break;
  1316.             case -5: fprintf(stderr,"Insufficient memory to load ",
  1317.                              "graphics driver.");
  1318.                      break;
  1319.             case 1 : term_name = "cga";
  1320.                      break;
  1321.             case 2 : term_name = "mcga";
  1322.                      break;
  1323.             case 3 : 
  1324.             case 4 : term_name = "egalib";
  1325.                      break;
  1326.             case 7 : term_name = "hercules";
  1327.                      break;
  1328.             case 8 : term_name = "att";
  1329.                      break;
  1330.             case 9 : term_name = "vgalib";
  1331.                      break;
  1332.             }
  1333.         closegraph();
  1334.         textmode(tinfo.currmode);
  1335.     clrscr();
  1336.     fprintf(stderr,"\tTC Graphics, driver %s  mode %s\n",c1,c2);
  1337.   return(term_name);
  1338. }
  1339. #endif /* __TURBOC__ */
  1340.  
  1341. /*
  1342.     This is always defined so we don't have to have command.c know if it
  1343.     is there or not.
  1344. */
  1345. #ifndef UNIXPLOT
  1346. UP_redirect(caller) int caller; 
  1347. {
  1348.     caller = caller;    /* to stop Turbo C complaining 
  1349.                          * about caller not being used */
  1350. }
  1351. #else
  1352. UP_redirect (caller)
  1353. int caller;
  1354. /*
  1355.     Unixplot can't really write to outfile--it wants to write to stdout.
  1356.     This is normally ok, but the original design of gnuplot gives us
  1357.     little choice.  Originally users of unixplot had to anticipate
  1358.     their needs and redirect all I/O to a file...  Not very gnuplot-like.
  1359.  
  1360.     caller:  1 - called from SET OUTPUT "FOO.OUT"
  1361.              2 - called from SET TERM UNIXPLOT
  1362.              3 - called from SET TERM other
  1363.              4 - called from SET OUTPUT
  1364. */
  1365. {
  1366.     switch (caller) {
  1367.     case 1:
  1368.     /* Don't save, just replace stdout w/outfile (save was already done). */
  1369.         if (unixplot)
  1370.             *(stdout) = *(outfile);  /* Copy FILE structure */
  1371.     break;
  1372.     case 2:
  1373.         if (!unixplot) {
  1374.             fflush(stdout);
  1375.             save_stdout = *(stdout);
  1376.             *(stdout) = *(outfile);  /* Copy FILE structure */
  1377.             unixplot = 1;
  1378.         }
  1379.     break;
  1380.     case 3:
  1381.     /* New terminal in use--put stdout back to original. */
  1382.         closepl();
  1383.         fflush(stdout);
  1384.         *(stdout) = save_stdout;  /* Copy FILE structure */
  1385.         unixplot = 0;
  1386.     break;
  1387.     case 4:
  1388.     /*  User really wants to go to normal output... */
  1389.         if (unixplot) {
  1390.             fflush(stdout);
  1391.             *(stdout) = save_stdout;  /* Copy FILE structure */
  1392.         }
  1393.     break;
  1394.     }
  1395. }
  1396. #endif
  1397.  
  1398.  
  1399. /* test terminal by drawing border and text */
  1400. /* called from command test */
  1401. test_term()
  1402. {
  1403.     register struct termentry *t = &term_tbl[term];
  1404.     char *str;
  1405.     int x,y, xl,yl, i;
  1406.     unsigned int xmax, ymax;
  1407.     char label[MAX_ID_LEN];
  1408.     int scaling;
  1409.  
  1410.     if (!term_init) {
  1411.        (*t->init)();
  1412.        term_init = TRUE;
  1413.     }
  1414.     screen_ok = FALSE;
  1415.     scaling = (*t->scale)(xsize, ysize);
  1416.     xmax = (unsigned int)(t->xmax * (scaling ? 1 : xsize));
  1417.     ymax = (unsigned int)(t->ymax * (scaling ? 1 : ysize));
  1418.     (*t->graphics)();
  1419.     /* border linetype */
  1420.     (*t->linetype)(-2);
  1421.     (*t->move)(0,0);
  1422.     (*t->vector)(xmax-1,0);
  1423.     (*t->vector)(xmax-1,ymax-1);
  1424.     (*t->vector)(0,ymax-1);
  1425.     (*t->vector)(0,0);
  1426.     (void) (*t->justify_text)(LEFT);
  1427.     (*t->put_text)(t->h_char*5,ymax-t->v_char*3,"Terminal Test");
  1428.     /* axis linetype */
  1429.     (*t->linetype)(-1);
  1430.     (*t->move)(xmax/2,0);
  1431.     (*t->vector)(xmax/2,ymax-1);
  1432.     (*t->move)(0,ymax/2);
  1433.     (*t->vector)(xmax-1,ymax/2);
  1434.     /* test width and height of characters */
  1435.     (*t->linetype)(-2);
  1436.     (*t->move)(  xmax/2-t->h_char*10,ymax/2+t->v_char/2);
  1437.     (*t->vector)(xmax/2+t->h_char*10,ymax/2+t->v_char/2);
  1438.     (*t->vector)(xmax/2+t->h_char*10,ymax/2-t->v_char/2);
  1439.     (*t->vector)(xmax/2-t->h_char*10,ymax/2-t->v_char/2);
  1440.     (*t->vector)(xmax/2-t->h_char*10,ymax/2+t->v_char/2);
  1441.     (*t->put_text)(xmax/2-t->h_char*10,ymax/2,
  1442.         "12345678901234567890");
  1443.     /* test justification */
  1444.     (void) (*t->justify_text)(LEFT);
  1445.     (*t->put_text)(xmax/2,ymax/2+t->v_char*6,"left justified");
  1446.     str = "centre+d text";
  1447.     if ((*t->justify_text)(CENTRE))
  1448.         (*t->put_text)(xmax/2,
  1449.                 ymax/2+t->v_char*5,str);
  1450.     else
  1451.         (*t->put_text)(xmax/2-strlen(str)*t->h_char/2,
  1452.                 ymax/2+t->v_char*5,str);
  1453.     str = "right justified";
  1454.     if ((*t->justify_text)(RIGHT))
  1455.         (*t->put_text)(xmax/2,
  1456.                 ymax/2+t->v_char*4,str);
  1457.     else
  1458.         (*t->put_text)(xmax/2-strlen(str)*t->h_char,
  1459.                 ymax/2+t->v_char*4,str);
  1460.     /* test text angle */
  1461.     str = "rotated ce+ntred text";
  1462.     if ((*t->text_angle)(1)) {
  1463.         if ((*t->justify_text)(CENTRE))
  1464.             (*t->put_text)(t->v_char,
  1465.                 ymax/2,str);
  1466.         else
  1467.             (*t->put_text)(t->v_char,
  1468.                 ymax/2-strlen(str)*t->h_char/2,str);
  1469.     }
  1470.     else {
  1471.         (void) (*t->justify_text)(LEFT);
  1472.         (*t->put_text)(t->h_char*2,ymax/2-t->v_char*2,"Can't rotate text");
  1473.     }
  1474.     (void) (*t->justify_text)(LEFT);
  1475.     (void) (*t->text_angle)(0);
  1476.     /* test tic size */
  1477.     (*t->move)(xmax/2+t->h_tic*2,0);
  1478.     (*t->vector)(xmax/2+t->h_tic*2,t->v_tic);
  1479.     (*t->move)(xmax/2,t->v_tic*2);
  1480.     (*t->vector)(xmax/2+t->h_tic,t->v_tic*2);
  1481.     (*t->put_text)(xmax/2+t->h_tic*2,t->v_tic*2+t->v_char/2,"test tics");
  1482.     /* test line and point types */
  1483.     x = xmax - t->h_char*4 - t->h_tic*4;
  1484.     y = ymax - t->v_char;
  1485.     for ( i = -2; y > t->v_char; i++ ) {
  1486.         (*t->linetype)(i);
  1487.         (void) sprintf(label,"%d",i);
  1488.         if ((*t->justify_text)(RIGHT))
  1489.             (*t->put_text)(x,y,label);
  1490.         else
  1491.             (*t->put_text)(x-strlen(label)*t->h_char,y,label);
  1492.         (*t->move)(x+t->h_char,y);
  1493.         (*t->vector)(x+t->h_char*4,y);
  1494.         if ( i >= -1 )
  1495.             (*t->point)(x+t->h_char*4+t->h_tic*2,y,i);
  1496.         y -= t->v_char;
  1497.     }
  1498.     /* test some arrows */
  1499.     (*t->linetype)(0);
  1500.     x = xmax/4;
  1501.     y = ymax/4;
  1502.     xl = t->h_tic*5;
  1503.     yl = t->v_tic*5;
  1504.     (*t->arrow)(x,y,x+xl,y,TRUE);
  1505.     (*t->arrow)(x,y,x+xl/2,y+yl,TRUE);
  1506.     (*t->arrow)(x,y,x,y+yl,TRUE);
  1507.     (*t->arrow)(x,y,x-xl/2,y+yl,FALSE);
  1508.     (*t->arrow)(x,y,x-xl,y,TRUE);
  1509.     (*t->arrow)(x,y,x-xl,y-yl,TRUE);
  1510.     (*t->arrow)(x,y,x,y-yl,TRUE);
  1511.     (*t->arrow)(x,y,x+xl,y-yl,TRUE);
  1512.     /* and back into text mode */
  1513.     (*t->text)();
  1514. }
  1515.  
  1516.  
  1517. #ifdef PC
  1518. /* output for some terminal types must be binary to stop non Unix computers
  1519.    changing \n to \r\n. 
  1520.    If the output is not STDOUT, the following code reopens outfile 
  1521.    with binary mode. */
  1522. void
  1523. reopen_binary()
  1524. {
  1525. char filename[MAX_ID_LEN+1];
  1526.  
  1527.     if (strcmp(outstr,"STDOUT")) {
  1528.         (void) fclose(outfile);
  1529.         (void) strcpy(filename,outstr+1);    /* remove quotes */
  1530.         filename[strlen(filename)-1] = '\0';
  1531.         if ( (outfile = fopen(filename,"wb")) == (FILE *)NULL ) {
  1532.             if ( (outfile = fopen(filename,"w")) == (FILE *)NULL ) {
  1533.                 os_error("cannot reopen file with binary type; output unknown",
  1534.                     NO_CARET);
  1535.             } 
  1536.             else {
  1537.     os_error("cannot reopen file with binary type; output reset to ascii", 
  1538.                     NO_CARET);
  1539.             }
  1540.         }
  1541.     }
  1542. }
  1543. #endif
  1544.  
  1545. #ifdef vms
  1546. /* these are needed to modify terminal characteristics */
  1547. #include <descrip.h>
  1548. #include <iodef.h>
  1549. #include <ttdef.h>
  1550. #include <tt2def.h>
  1551. #include <dcdef.h>
  1552. #include <ssdef.h>
  1553. #include <stat.h>
  1554. #include <fab.h>
  1555. static unsigned short   chan;
  1556. static int  old_char_buf[3], cur_char_buf[3];
  1557. $DESCRIPTOR(sysoutput_desc,"SYS$OUTPUT");
  1558.  
  1559. char *vms_init()
  1560. /*
  1561.  * Determine if we have a regis terminal
  1562.  * and save terminal characteristics
  1563. */
  1564. {
  1565.    /* Save terminal characteristics in old_char_buf and
  1566.    initialise cur_char_buf to current settings. */
  1567.    int i;
  1568.    sys$assign(&sysoutput_desc,&chan,0,0);
  1569.    sys$qiow(0,chan,IO$_SENSEMODE,0,0,0,old_char_buf,12,0,0,0,0);
  1570.    for (i = 0 ; i < 3 ; ++i) cur_char_buf[i] = old_char_buf[i];
  1571.    sys$dassgn(chan);
  1572.  
  1573.    /* Test if terminal is regis */
  1574.    if ((cur_char_buf[2] & TT2$M_REGIS) == TT2$M_REGIS) return("regis");
  1575.    return(NULL);
  1576. }
  1577.  
  1578. void
  1579. vms_reset()
  1580. /* set terminal to original state */
  1581. {
  1582.    int i;
  1583.    sys$assign(&sysoutput_desc,&chan,0,0);
  1584.    sys$qiow(0,chan,IO$_SETMODE,0,0,0,old_char_buf,12,0,0,0,0);
  1585.    for (i = 0 ; i < 3 ; ++i) cur_char_buf[i] = old_char_buf[i];
  1586.    sys$dassgn(chan);
  1587. }
  1588.  
  1589. void
  1590. term_mode_tek()
  1591. /* set terminal mode to tektronix */
  1592. {
  1593.    long status;
  1594.    if (outfile != stdout) return; /* don't modify if not stdout */
  1595.    sys$assign(&sysoutput_desc,&chan,0,0);
  1596.    cur_char_buf[0] = 0x004A0000 | DC$_TERM | (TT$_TEK401X<<8);
  1597.    cur_char_buf[1] = (cur_char_buf[1] & 0x00FFFFFF) | 0x18000000;
  1598.  
  1599.    cur_char_buf[1] &= ~TT$M_CRFILL;
  1600.    cur_char_buf[1] &= ~TT$M_ESCAPE;
  1601.    cur_char_buf[1] &= ~TT$M_HALFDUP;
  1602.    cur_char_buf[1] &= ~TT$M_LFFILL;
  1603.    cur_char_buf[1] &= ~TT$M_MECHFORM;
  1604.    cur_char_buf[1] &= ~TT$M_NOBRDCST;
  1605.    cur_char_buf[1] &= ~TT$M_NOECHO;
  1606.    cur_char_buf[1] &= ~TT$M_READSYNC;
  1607.    cur_char_buf[1] &= ~TT$M_REMOTE;
  1608.    cur_char_buf[1] |= TT$M_LOWER;
  1609.    cur_char_buf[1] |= TT$M_TTSYNC;
  1610.    cur_char_buf[1] |= TT$M_WRAP;
  1611.    cur_char_buf[1] &= ~TT$M_EIGHTBIT;
  1612.    cur_char_buf[1] &= ~TT$M_MECHTAB;
  1613.    cur_char_buf[1] &= ~TT$M_SCOPE;
  1614.    cur_char_buf[1] |= TT$M_HOSTSYNC;
  1615.  
  1616.    cur_char_buf[2] &= ~TT2$M_APP_KEYPAD;
  1617.    cur_char_buf[2] &= ~TT2$M_BLOCK;
  1618.    cur_char_buf[2] &= ~TT2$M_DECCRT3;
  1619.    cur_char_buf[2] &= ~TT2$M_LOCALECHO;
  1620.    cur_char_buf[2] &= ~TT2$M_PASTHRU;
  1621.    cur_char_buf[2] &= ~TT2$M_REGIS;
  1622.    cur_char_buf[2] &= ~TT2$M_SIXEL;
  1623.    cur_char_buf[2] |= TT2$M_BRDCSTMBX;
  1624.    cur_char_buf[2] |= TT2$M_EDITING;
  1625.    cur_char_buf[2] |= TT2$M_INSERT;
  1626.    cur_char_buf[2] |= TT2$M_PRINTER;
  1627.    cur_char_buf[2] &= ~TT2$M_ANSICRT;
  1628.    cur_char_buf[2] &= ~TT2$M_AVO;
  1629.    cur_char_buf[2] &= ~TT2$M_DECCRT;
  1630.    cur_char_buf[2] &= ~TT2$M_DECCRT2;
  1631.    cur_char_buf[2] &= ~TT2$M_DRCS;
  1632.    cur_char_buf[2] &= ~TT2$M_EDIT;
  1633.    cur_char_buf[2] |= TT2$M_FALLBACK;
  1634.  
  1635.    status = sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
  1636.    if (status == SS$_BADPARAM) {
  1637.       /* terminal fallback utility not installed on system */
  1638.       cur_char_buf[2] &= ~TT2$M_FALLBACK;
  1639.       sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
  1640.    }
  1641.    else {
  1642.       if (status != SS$_NORMAL)
  1643.          lib$signal(status,0,0);
  1644.    }
  1645.    sys$dassgn(chan);
  1646. }
  1647.  
  1648. void
  1649. term_mode_native()
  1650. /* set terminal mode back to native */
  1651. {
  1652.    int i;
  1653.    if (outfile != stdout) return; /* don't modify if not stdout */
  1654.    sys$assign(&sysoutput_desc,&chan,0,0);
  1655.    sys$qiow(0,chan,IO$_SETMODE,0,0,0,old_char_buf,12,0,0,0,0);
  1656.    for (i = 0 ; i < 3 ; ++i) cur_char_buf[i] = old_char_buf[i];
  1657.    sys$dassgn(chan);
  1658. }
  1659.  
  1660. void
  1661. term_pasthru()
  1662. /* set terminal mode pasthru */
  1663. {
  1664.    if (outfile != stdout) return; /* don't modify if not stdout */
  1665.    sys$assign(&sysoutput_desc,&chan,0,0);
  1666.    cur_char_buf[2] |= TT2$M_PASTHRU;
  1667.    sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
  1668.    sys$dassgn(chan);
  1669. }
  1670.  
  1671. void
  1672. term_nopasthru()
  1673. /* set terminal mode nopasthru */
  1674. {
  1675.    if (outfile != stdout) return; /* don't modify if not stdout */
  1676.    sys$assign(&sysoutput_desc,&chan,0,0);
  1677.    cur_char_buf[2] &= ~TT2$M_PASTHRU;
  1678.    sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
  1679.    sys$dassgn(chan);
  1680. }
  1681.  
  1682. void
  1683. reopen_binary()
  1684. /* close the file outfile outfile and reopen it with binary type
  1685.    if not already done or outfile == stdout */
  1686. {
  1687.    stat_t stat_buf;
  1688.    char filename[MAX_ID_LEN+1];
  1689.    if (outfile != stdout) { /* don't modify if not stdout */
  1690.       if (!fstat(fileno(outfile),&stat_buf)) {
  1691.          if (stat_buf.st_fab_rfm != FAB$C_FIX) {
  1692.             /* modify only if not already done */
  1693.             (void) fclose(outfile);
  1694.             (void) strcpy(filename,outstr+1);   /* remove quotes */
  1695.             filename[strlen(filename)-1] = '\0';
  1696.             (void) delete(filename);
  1697.             if ((outfile = fopen(filename,"wb","rfm=fix","bls=512","mrs=512"))
  1698.                 == (FILE *)NULL ) {
  1699.                if ( (outfile = fopen(filename,"w")) == (FILE *)NULL ) {
  1700.                  os_error("cannot reopen file with binary type; output unknown",
  1701.                            NO_CARET);
  1702.                }
  1703.                else {
  1704.           os_error("cannot reopen file with binary type; output reset to ascii",
  1705.                            NO_CARET);
  1706.                }
  1707.             }
  1708.          }
  1709.       }
  1710.       else{
  1711.          os_error("cannot reopen file with binary type; output remains ascii",
  1712.                   NO_CARET);
  1713.       }
  1714.    }
  1715. }
  1716.  
  1717. void
  1718. fflush_binary()
  1719. {
  1720.    typedef short int INT16;     /* signed 16-bit integers */
  1721.    register INT16 k;            /* loop index */
  1722.    if (outfile != stdout) {
  1723.        /* Stupid VMS fflush() raises error and loses last data block
  1724.           unless it is full for a fixed-length record binary file.
  1725.           Pad it here with NULL characters. */
  1726.        for (k = (INT16)((*outfile)->_cnt); k > 0; --k)
  1727.           putc('\0',outfile);
  1728.        fflush(outfile);
  1729.    }
  1730. }
  1731. #endif
  1732.